/**
 * 
 */
package com.great.meal.search.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author lenovo
 *
 */
@Entity
@Table(name="t_senderrecord")
public class SenderRecord implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3706652477717251618L;
	private Long senderRecordId;
	private Sender senderId;
	private Order orderId;
	private Date time;
	
	@Override
	public boolean equals(Object obj) {
		if(this == obj) return true;
		if(!(obj instanceof SenderRecord)) return false;
		
		final SenderRecord record = (SenderRecord)obj;
		if(!(record.getSenderId().equals(getSenderId()))) return false;
		if(!(record.getSenderRecordId().equals(getSenderRecordId()))) return false;
		if(!(record.getOrderId().equals(getOrderId()))) return false;
		if(!(record.getTime().equals(getTime()))) return false;
		return false;
	}
	@Override
	public int hashCode() {
		int result = senderRecordId != null ? senderRecordId.hashCode() : 0;
		result = result * 31 + (senderId != null ? senderId.hashCode() : 0);
		result = result * 31 + (orderId != null ? orderId.hashCode() : 0);
		result = result * 31 + (time != null ? time.hashCode() : 0);
		
		return result;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getSenderRecordId() {
		return senderRecordId;
	}
	public void setSenderRecordId(Long senderRecordId) {
		this.senderRecordId = senderRecordId;
	}
	
	@OneToOne
	@JoinColumn(name="senderId")
	public Sender getSenderId() {
		return senderId;
	}
	public void setSenderId(Sender senderId) {
		this.senderId = senderId;
	}
	
	@OneToOne
	@JoinColumn(name="orderId")
	public Order getOrderId() {
		return orderId;
	}
	public void setOrderId(Order orderId) {
		this.orderId = orderId;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="recordTime")
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	
	
}
